﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Shell.Interop;

namespace SolutionSettings_UnitTests {
    struct ActivityLogEntry {
        public uint type;
        public string source;
        public string description;
        public Guid? guid;
        public string path;
        public int? hr;
    }
    
    class MockActivityLog : IVsActivityLog {
        List<ActivityLogEntry> EntryList = new List<ActivityLogEntry>();
        public int LogHresult { get; set; }

        public IEnumerable<ActivityLogEntry> Entries {
            get {
                return EntryList;
            }
        }

        public void Clear() {
            EntryList.Clear();
        }

        public bool Contains(uint? type = null, string source = null, string description = null, Guid? guid = null, string path = null, int? hr = null) {
            foreach (var entry in EntryList) {
                if ((!type.HasValue || type.Value == entry.type) &&
                    (source == entry.source) &&
                    (description == entry.description) &&
                    (guid == entry.guid) &&
                    (path == entry.path) &&
                    (hr == entry.hr)) {
                    return true;
                }
            }
            return false;
        }

        public int LogEntry(uint actType, string pszSource, string pszDescription) {
            EntryList.Add(new ActivityLogEntry {
                type = actType,
                source = pszSource,
                description = pszDescription
            });
            return LogHresult;
        }

        public int LogEntryGuid(uint actType, string pszSource, string pszDescription, Guid guid) {
            EntryList.Add(new ActivityLogEntry {
                type = actType,
                source = pszSource,
                description = pszDescription,
                guid = guid
            });
            return LogHresult;
        }

        public int LogEntryGuidHr(uint actType, string pszSource, string pszDescription, Guid guid, int hr) {
            EntryList.Add(new ActivityLogEntry {
                type = actType,
                source = pszSource,
                description = pszDescription,
                guid = guid,
                hr = hr
            });
            return LogHresult;
        }

        public int LogEntryGuidHrPath(uint actType, string pszSource, string pszDescription, Guid guid, int hr, string pszPath) {
            EntryList.Add(new ActivityLogEntry {
                type = actType,
                source = pszSource,
                description = pszDescription,
                guid = guid,
                hr = hr,
                path = pszPath
            });
            return LogHresult;
        }

        public int LogEntryGuidPath(uint actType, string pszSource, string pszDescription, Guid guid, string pszPath) {
            EntryList.Add(new ActivityLogEntry {
                type = actType,
                source = pszSource,
                description = pszDescription,
                guid = guid,
                path = pszPath
            });
            return LogHresult;
        }

        public int LogEntryHr(uint actType, string pszSource, string pszDescription, int hr) {
            EntryList.Add(new ActivityLogEntry {
                type = actType,
                source = pszSource,
                description = pszDescription,
                hr = hr
            });
            return LogHresult;
        }

        public int LogEntryHrPath(uint actType, string pszSource, string pszDescription, int hr, string pszPath) {
            EntryList.Add(new ActivityLogEntry {
                type = actType,
                source = pszSource,
                description = pszDescription,
                hr = hr,
                path = pszPath
            });
            return LogHresult;
        }

        public int LogEntryPath(uint actType, string pszSource, string pszDescription, string pszPath) {
            EntryList.Add(new ActivityLogEntry {
                type = actType,
                source = pszSource,
                description = pszDescription,
                path = pszPath
            });
            return LogHresult;
        }
    }
}
